package com.example.smart.room.repository.base

import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch

abstract class BaseRepository {
    private val baseScope = CoroutineScope(Dispatchers.IO)

    fun launch(request: suspend CoroutineScope.() -> Unit) {
        baseScope.launch {
            request.invoke(this)
        }
    }

    fun second(request: suspend CoroutineScope.() -> Unit) {
        val newScope = CoroutineScope(Dispatchers.IO)
        newScope.launch {
            request.invoke(newScope)
        }
    }

    open suspend fun getLastUpdateTime(result: suspend (String) -> Unit) {}
}